package com.dimples.dd.system.model.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import java.util.Date;
import java.util.List;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/8/8
 */
@Schema(description = "OAuth2 客户端 Vo")
@Data
public class OAuth2ClientPageVO {

    @Schema(description = "编号", example = "1024")
    private String id;

    @Schema(description = "客户端编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "dd")
    @NotNull(message = "客户端编号不能为空")
    private String clientId;

    @Schema(description = "客户端密钥", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
    @NotNull(message = "客户端密钥不能为空")
    private String clientSecret;

    @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dd")
    @NotNull(message = "应用名不能为空")
    private String clientName;

    @Schema(description="客户端发布时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date clientIdIssuedAt;

    @Schema(description="密钥有效期")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date clientSecretExpiresAt;

    @Schema(description="客户端身份验证方法 (client_secret_basic/client_secret_post/client_secret_jwt)")
    private String clientAuthenticationMethods;

    @Schema(description = "授权类型，参见 AuthorizationGrantType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "password")
    @NotNull(message = "授权类型不能为空")
    private List<String> authorizationGrantTypes;

    @Schema(description="重定向地址")
    private String redirectUris;

    @Schema(description="登出重定向地址")
    private String postLogoutRedirectUris;

    @Schema(description = "授权范围", example = "user_info")
    private List<String> scopes;

    @Schema(description = "应用图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.example.cn/xx.png")
    @NotNull(message = "应用图标不能为空")
    @URL(message = "应用图标的地址不正确")
    private String clientLogo;

    @Schema(description = "应用描述", example = "我是一个应用")
    private String clientDescription;

    @Schema(description = "状态，参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @NotNull(message = "状态不能为空")
    private Integer status;

    @Schema(description = "Token 有效期（单位 s）", requiredMode = Schema.RequiredMode.REQUIRED, example = "3600")
    @NotNull(message = "Token 有效期不能为空")
    private Long accessTokenTimeToLive;

    @Schema(description = "Refresh Token 有效期（单位 s）", requiredMode = Schema.RequiredMode.REQUIRED, example = "3600")
    private Long refreshTokenTimeToLive;

}
